package com.nightsoul.hadoop1.test.join;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reporter;

import com.nightsoul.hadoop1.test.TextPair;
import com.nightsoul.hadoop1.test.junit.NcdcRecordParser;

/**
 * 标记气象记录实现reduce端联接的mapper
 * @author zj
 *
 */
public class JoinRecordMapper extends MapReduceBase 
	implements Mapper<LongWritable, Text, TextPair, Text> {
	private NcdcRecordParser parser = new NcdcRecordParser();
	
	@Override
	public void map(LongWritable key, Text value,
			OutputCollector<TextPair, Text> output, Reporter reporter)
			throws IOException {

		parser.parse(value);
		output.collect(new TextPair(parser.getStationId(), "1"), value);	
	}

}
